<?
include("includes/functions.php");

if (!empty($delete)) {
	
}
 vcxvcxbvcbvcxbvcxb
// Get all messages
/*
$sql = "SELECT * from oa_sys_Users2";
$result = mysql_db_query($dbname,$sql);
$rows = mysql_num_rows($result);
*/
include("includes/header.php"); ?>
<script language="JavaScript">
function confirmSubmit() {
	var agree=confirm("Are you sure you want to delete this Message?");
	if (agree)
		return true ;
	else
		return false ;
}

</script>
<div id="header2">
	<? include("includes/main_menu.php"); ?>
</div>
<? include("includes/sub_menu_contacts.php"); ?>
<div id="subNoLogin"></div>
<div id="pageHeader"><h1 class="headerContacts">Contact Manager : <b>View General Site Contacts</b></h1></div>

<div id="pageInstructions"><b>Coming Soon!</b></div>

<div id="datatable">
<table class="datatable" summary="A List of Current Messages">
	<caption>Current Messages</caption>
	
	<? if ($rows > 0) { ?>
	<tr>
		<th scope="col"></th>
		<th scope="col">User Full Name</th>
		<th scope="col">Login User Name</th>
		<th scope="col">Login Password</th>
		<th scope="col">Email</th>
		<th scope="col">User Level</th>
	</tr>
	<?
	$i = 0;
	while ($value = mysql_fetch_assoc($result)) {	
		if (($i % 2) > 0) { $class = "altrow"; }
		else { $class = null; }
		
		$UID       = $value[User_PID];
		$uName     = $value[UserNameFull];
  		$uUserid   = $value[UserLogonName];
  		$uPassword = $value[UserLogonPass];
  		$uEmail    = $value[UserEmailAddress];
  		$uLevel    = $value[UserAccountLevel];
  		
  		$uLinkEmail = $uEmail;
  		
  		if (strlen($uUserid) > 25) { $uUserid = substr($uUserid,0,25)."..."; }
  		if (strlen($uEmail) > 25) { $uEmail = substr($uEmail,0,25)."..."; }
  		
  		switch ($uLevel) {
  			case 1:
   			$uLevelText = "<font color=#FF6600>Data Entry</font>";
   			break;
   			case 2:
   			$uLevelText = "<font color=blue>Data Manager</font>";
   			break;
   			case 3:
   			$uLevelText = "<font color=#339900>Super User</font>";
   			break;
     	}

	?>
	<tr class="<?=$class; ?>">
		<td class="nav"><div class="buttons"></a><a href="user_edit.php?UID=<?=$UID; ?>" class="buttonEdit" title="Edit This User"><i>Edit</i></a><a href="<?=$PHP_SELF; ?>?delete=1&UID=<?=$UID; ?>" class="buttonDelete" onclick="return confirmSubmit();" title="Delete This User"><i>Delete</i></a></div></td>
		<td><?=$uName; ?></td>
		<td><b><?=$uUserid; ?></b></td>
		<td><b><?=$uPassword; ?></b></td>
		<td><a href="mailto:<?=$uEmail; ?>" title="Send Email to <?=$uName; ?>: [<?=$uLinkEmail; ?>]"><?=$uEmail; ?></a></td>
		<td><?=$uLevelText; ?></td>
	</tr>
	<?  $i++; }
		} else { ?>
	<tr><td>
	There are no messages at this time.
	</td></tr>
	<? } ?>
	
</table>
</div>		


<? include("includes/footer.php"); ?>turn true;
	}
}

function checkAll() {
	for (var j = 0; j <= <? echo $limit-1; ?>; j++) {
		box1 = eval("document.main.image_" + j); 		
		if (box1.checked == false) box1.checked = true;			
   }
}

function uncheckAll() {
	for (var j = 0; j <= <? echo $limit-1; ?>; j++) {
		box1 = eval("document.main.image_" + j); 			
		if (box1.checked == true) box1.checked = false;			
   }
}

</script>
<div id="header2">
	<? include("includes/main_menu.php"); ?>
</div>
<? include("includes/sub_menu_sp.php"); ?>
<div id="subNoLogin"></div>
<div id="pageHeader"><h1 class="headerContacts">Service Provider Manager : <b>View All Service Providers</b></h1></div>

<div id="pageInstructions"><img src="images/help.gif"> Below is a list of existing Service Provider Organizations. Use the
buttons to the left of each entry to View, Edit or Delete the service provider.<br><br>

Check the 'Visible' box to the right of each Service Provider and click SAVE to make them appear
on the website.
<p></p>
</div>

<div id="datatable">
<? include("includes/provider_search_form.php"); ?>

<form action="<?=$PHP_SELF; ?>?makeVisible=1&<?=$linkString; ?>" method="POST">
<input type="hidden" name="page" value="<?=$page; ?>">
<input type="hidden" name="start" value="<?=$start; ?>">
<input type="hidden" name="limit" value="<?=$limit; ?>">
<input type="hidden" name="search" value="<?=$search; ?>">

<table class="datatable" summary="A List of Current Service Providers">
	<caption>
	<?
	if (isset($visible)) { echo "View Invisible Service Providers Only : [<a href=\"$PHP_SELF\">View All</a>]"; }
	else { echo "View All Service Providers"; }
	?>
	</caption>
	
	<? if ($rows > 0) { ?>
	<tr>
		<th scope="col"></th>
		<th scope="col">Organization Name</th>
		<th scope="col">Phone</th>
		<th scope="col">Email</th>
		<th scope="col">Updated</th>
		<th scope="col">Visible</th>
	</tr>
	<?
	$i = 0;
	while ($value = mysql_fetch_assoc($result)) {	
		if (($i % 2) > 0) { $class = "altrow"; }
		else { $class = null; }
		
		$PID = $value[Provider_PID];
		$pName = $value[ProviderNameFull];
  		$pMainSiteID = $value[ProviderMainSite_ID];
  		$pVisible = $value[IsVisible];
  		$pUpdated = $value[ModDate];
		
		// Get service provider contact information
		$sql2 = "SELECT * from oa_btb_Sites WHERE Site_PID = '$pMainSiteID' AND IsVisible = '1'";
		$result2 = mysql_db_query($dbname,$sql2);
		$sRow = mysql_fetch_assoc($result2);
		$sName    = stripslashes($sRow[SiteName]);
		$sStreet1 = $sRow[SiteStreet1];
		$sStreet2 = $sRow[SiteStreet2];
		$sCity    = $sRow[SiteCity];
		$sState   = $sRow[SiteStateAbbr];
		$sZip     = $sRow[SiteZipCode];
		$sPhone   = $sRow[SitePhoneMain];
		$sEmail   = $sRow[SiteEmailGeneral];
		$sURL     = $value[ProviderWebURL];
	?>
	<tr class="<?=$class; ?>">
		<td class="nav"><div class="buttons"><a href="service_provider_view.php?PID=<?=$PID; ?>" class="buttonView" title="View Details"><i>View Details</i></a><a href="service_provider_edit.php?PID=<?=$PID; ?>" class="buttonEdit" title="Edit"><i>Edit</i></a><a href="<?=$PHP_SELF; ?>?delete=1&PID=<?=$PID; ?>&start=<?=$start; ?>&page=<?=$page; ?>&limit=<?=$limit; ?>&<?=$linkString; ?>" class="buttonDelete" onclick="return confirmSubmit();" title="Delete"><i>Delete</i></a></div></td>
		<td><a href="service_provider_view.php?PID=<?=$PID; ?>" title="Click to View Details for <?=$pName; ?>"><?=$pName; ?></a></td>
		<td><?=$sPhone; ?></td>
		<td><a href="mailto:<?=$sEmail; ?>" title="Send Email to <?=$pName; ?>"><?=$sEmail; ?></a></td>
		<td align="right"><? timestamp_to_date($pUpdated); ?></td>
		<td align="center">
			<input type="checkbox" name="v<?=$i; ?>" value="1" <? if($pVisible == 1) { echo "checked"; } ?>>
			<input type="hidden" name="PID<?=$i; ?>" value="<?=$PID; ?>">
		</td>
	</tr>
	<?  $i++; }
		} else { ?>
	<tr><td>
	There are no service providers entered at this time.
	</td></tr>
	<? } ?>
	
</table>
<input type="hidden" name="no" value="<? $no = $i-1; echo "$no"; ?>">
<? if ($rows > 0) { ?>
<div align="right"><br><input type="submit" value="Update Visible"></div>
<? } ?>
</form>
</div>		


<? include("includes/footer.php"); ?>
